home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 466_01 / SRC / FMTTEXT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-20  |  2.1 KB  |  119 lines

  1. #include <afx.h>
  2. #include <afxtempl.h>
  3. #include "parse.h"
  4. #include "topiclog.h"
  5. #include "input.h"
  6. #include "fmt.h"
  7. #include "fmtif.h"
  8. #include "fmttag.h"
  9. #include "fmttext.h"
  10. #include "errmsg.h"
  11.  
  12.  
  13. /******************************************************/
  14. // Tag list
  15. /******************************************************/
  16.  
  17. TAGSPEC gtagsTextSection[] =
  18. {
  19.     CFmtListText::tagTag,              "tag",
  20.     CFmtListText::tagFormat,           "format",
  21.     CFmtListText::tagIf,              "if",
  22.     -1,        NULL,
  23. };
  24.  
  25.  
  26. /******************************************************/
  27. // Format class
  28. /******************************************************/
  29.  
  30. CFmtText::CFmtText(void) : CFmtTag(1)
  31. {
  32. }
  33.  
  34. /******************************************************/
  35. // List class
  36. /******************************************************/
  37.  
  38. TAGSPEC *CFmtListText::FmtTagList(void)
  39. {
  40.     return gtagsTextSection;
  41. }
  42.     
  43.  
  44. int CFmtListText::ParseEntry(CFmtInput &in)
  45. {
  46.     int nRet;
  47.  
  48.     CFmtText *pNew;
  49.  
  50.     pNew = (CFmtText *)m_pNew;
  51.  
  52.     switch(m_nTag)
  53.     {
  54.     // Parent
  55.  
  56.     case tagTag:
  57.         
  58.         // Expect: .tag = name, output, fields
  59.  
  60.         if(in.m_nTokens != 3)
  61.             return fmterrBadEntryCount;
  62.  
  63.         if(!CheckOutputType(in, 1))
  64.             return 0;
  65.  
  66.         nRet = CheckAddTag();
  67.         if(nRet)
  68.             return nRet;
  69.  
  70.         m_pNew = pNew = new CFmtText;
  71.  
  72.         m_nState.Tag = TRUE;
  73.  
  74.         // Record source file information.
  75.  
  76.         pNew->SetSource(in.m_nFile, in.m_lCurLine);
  77.  
  78.         // Get the required Name field.
  79.         
  80.         nRet = ParseName(pNew->m_sName, in.m_aszTokens[0]);
  81.         if(nRet)
  82.             return nRet;        
  83.  
  84.         // Get the required number of fields
  85.         
  86.         nRet = ParseNumFields(pNew->m_nNumFields, in.m_aszTokens[2]);
  87.         if(nRet)
  88.             return nRet;
  89.         
  90.         break;
  91.     
  92.     case tagIf:
  93.         
  94.         nRet = ParseIf(*pNew, in);
  95.         if(nRet)
  96.            return nRet;
  97.  
  98.         break;
  99.  
  100.     // Text formatting string
  101.  
  102.     case tagFormat:
  103.  
  104.         // expect: .pre= format string
  105.  
  106.         nRet = SetFmtString(in, 0);
  107.  
  108.         if(nRet)
  109.             return nRet;
  110.         break;
  111.  
  112.     default:
  113.         return fmterrBadFmtEntry;
  114.     }
  115.  
  116.     return 0;
  117. }
  118.  
  119.